package com.example.app.data.enum

import com.example.app.R

enum class ResState(
    var label: String,
    var value: Any,
    var key: String
) {
    //请求类型
    RES_SUCCESS(
        "成功",
        0,
        "RES_SUCCESS"
    ),
    RES_FAILURE(
        "失败",
        1,
        "RES_FAILURE"
    );

    companion object {
        fun getVarByLabel(label: String): ResState? {
            values().forEach {
                if (label == it.label) return it
            }
            return null
        }

        fun getVarByValue(value: Any): ResState? {
            values().forEach {
                if (value == it.value) return it
            }
            return null
        }

        fun getVarByKey(key: String): ResState? {
            values().forEach {
                if (it.key == key) return it
            }
            return null
        }
    }
}